package com.zyh.homeworkzhuantike;

import java.util.Random;
import java.util.Scanner;

public class Test19 {
    public static void main(String[] args) {
        /*
        9.	完成课上猜数字的小游戏。提示：使用Random随机数对象
         */
        Random random = new Random();
        int rNum = random.nextInt(10);
        System.out.println("请输入您猜的数字：");
        boolean b = true;
        while (b) {
            int num = new Scanner(System.in).nextInt();
            if (num == rNum) {
                b = false;
                System.out.println("猜对了");
            } else if (num < rNum) {
                System.out.println("您猜的数小了");
            } else {
                System.out.println("您猜的数大了了");
            }
        }
    }
}
